package com.itboye.api.domain;

import com.github.pagehelper.Page;
import com.itboye.api.model.ByResponseData;
import com.itboye.mybatis.helper.ByPageInfoHelper;
import com.itboye.mybatis.viewmodel.CompanyApplyInfoModel;
import com.itboye.services.recruit.interfaces.ICompanyApplyInfoService;
import com.itboye.system.exception.ByBaseException;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;

/**
 * CompanyApplyDomain.java
 * Created on  2016/8/10 18:42
 * 版本       修改时间          作者      修改内容
 * V1.0.1    2016/8/10      hebidu    初始版本
 * <p>
 * Copyright (c) 2013 杭州博也网络科技有限公司 版权所有
 * HANGZHOU BOYE TECHNOLOGY CO.,LTD. All Rights Reserved.
 */
@Component("CompanyApplyInfoDomain")
public class CompanyApplyInfoDomain extends BaseDomain {

    @Resource
    private ICompanyApplyInfoService companyApplyInfoService;

    /**
     * 用户收到的简历
     * @return
     * @throws ByBaseException
     * @throws UnsupportedEncodingException
     */
    public ByResponseData receive() throws ByBaseException, UnsupportedEncodingException {
        checkApiVersion("100");

        Integer uid = getIntegerParam("uid");
        Integer pageNum = getIntegerParam("page_num",1);
        Integer pageSize = getIntegerParam("page_size",10);
        assertNotNull(uid,"缺少用户ID");

        String fields = null;
        String orders = "create_time desc";

        HashMap<String,String> params = new HashMap<String, String>();
        params.put("uid",""+uid);
        ByPageInfoHelper<CompanyApplyInfoModel> applyInfoModelPage = companyApplyInfoService.queryByPaging(params,pageNum,pageSize,fields,orders);

        return success(applyInfoModelPage);
    }

    /**
     * 学生用户申请的岗位
     * @return
     * @throws ByBaseException
     * @throws UnsupportedEncodingException
     */
    public ByResponseData apply() throws ByBaseException, UnsupportedEncodingException {
        checkApiVersion("100");

        Integer uid = getIntegerParam("uid");
        Integer pageNum = getIntegerParam("page_num",1);
        Integer pageSize = getIntegerParam("page_size",10);

        assertNotNull(uid,"缺少用户ID");
        String fields = null;
        String orders = "create_time desc";

        HashMap<String,String> params = new HashMap<String, String>();
        params.put("resume_uid",""+uid);
        ByPageInfoHelper<CompanyApplyInfoModel> applyInfoModelPage = companyApplyInfoService.queryByPaging(params,pageNum,pageSize,fields,orders);

        return success(applyInfoModelPage);
    }

}
